<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    6. ZigZag Conversion
   </h1>
   <p>
    The string
    <code>
     "PAYPALISHIRING"
    </code>
    is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
   </p>
   <pre>
P   A   H   N
A P L S I I G
Y   I   R
</pre>
   <p>
    And then read line by line:
    <code>
     "PAHNAPLSIIGYIR"
    </code>
   </p>
   <p>
    Write the code that will take a string and make this conversion given a number of rows:
   </p>
   <pre>
string convert(string s, int numRows);</pre>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> s = "PAYPALISHIRING", numRows = 3
<strong>Output:</strong> "PAHNAPLSIIGYIR"
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> s = "PAYPALISHIRING", numRows =&nbsp;4
<strong>Output:</strong>&nbsp;"PINALSIGYAHRPI"
<strong>Explanation:</strong>

P     I    N
A   L S  I G
Y A   H R
P     I</pre>
  </div>
  <div>
   <h1 class="question_title">
    6. Z 字形变换
   </h1>
   <p>
    将一个给定字符串根据给定的行数，以从上往下、从左到右进行&nbsp;Z 字形排列。
   </p>
   <p>
    比如输入字符串为
    <code>
     "LEETCODEISHIRING"
    </code>
    &nbsp;行数为 3 时，排列如下：
   </p>
   <pre>L   C   I   R
E T O E S I I G
E   D   H   N
</pre>
   <p>
    之后，你的输出需要从左往右逐行读取，产生出一个新的字符串，比如：
    <code>
     "LCIRETOESIIGEDHN"
    </code>
    。
   </p>
   <p>
    请你实现这个将字符串进行指定行数变换的函数：
   </p>
   <pre>string convert(string s, int numRows);</pre>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre><strong>输入:</strong> s = "LEETCODEISHIRING", numRows = 3
<strong>输出:</strong> "LCIRETOESIIGEDHN"
</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong> s = "LEETCODEISHIRING", numRows =&nbsp;4
<strong>输出:</strong>&nbsp;"LDREOEIIECIHNTSG"
<strong>解释:</strong>

L     D     R
E   O E   I I
E C   I H   N
T     S     G</pre>
  </div>
 </body>
</html>